let editing = false;
$("#svg-canvas").on("click", e => {
    if (!editing) {
        editing = true;
        let newLine = $(document.createElementNS("http://www.w3.org/2000/svg", "line"));
        newLine.attr({
            "x1": `${e.pageX}`,
            "y1": `${e.pageY}`,
            "x2": `${e.pageX}`,
            "y2": `${e.pageY}`,
            "stroke": "dodgerblue",
            "stroke-width": "2",
        });
        $(e.target).append(newLine);
        $(e.target).on("mousemove", e2 => {
            newLine.attr({
                "x2": `${e2.pageX}`,
                "y2": `${e2.pageY}`,
            });
        });
    } else {
        editing = false;
        $(e.target).off("mousemove")
    }
})